<?php
//=========================
//Vuong Van Binh
//Wanbin@vietnambiz.com
//=========================
include ADMIN_INCLUDE_DIR."/header.php";
//========================================
active();
verified();
$rs_member = get_all_member_page("personal");

//========================================
?>
<div class="container_l">
    <div class="title_user"><img src="images/icon1.gif" />Thành viên

        <span style="float:right; padding:2px; display:inline; margin-top:5px; margin-right:280px;">
            <form action="" method="get" name="frm_search">
                <input type="hidden" name="module" value="member" />
				Tìm kiếm :<input type="text" name="keyword" style="height:22px;" value="<?php echo htmlentities_utf8($_GET["keyword"]); ?>" />
                <select name="mode" id="mode" style="height:28px; width:120px; font-size:11px; font-weight:bold; color:#375B91; text-transform:none">
                    <?php
                    if($_GET["mode"]=="email") {
                        echo '<option value="username">Tên đăng nhập</option>';
                        echo "<option value='fullname'>Tên đầy đủ</option>";
                        echo "<option value='email' selected='selected'>Email</option>";
                    }else if($_GET["mode"]=="fullname") {
                            echo '<option value="username">Tên đăng nhập</option>';
                            echo "<option value='fullname' selected='selected'>Tên đầy đủ</option>";
                            echo '<option value="email">Email</option>';
                        }else {
                            echo "<option value='username' selected='selected'>Tên đăng nhập</option>";
                            echo '<option value="fullname">Tên đầy đủ</option>';
                            echo '<option value="email">Email</option>';
                        }
                    ?>
                </select>
                <input type="submit" name="search" value="Tìm kiếm" class="button" style="float:right" />
            </form>
        </span>

    </div>
    <div class="table_user">
        <div class="table_user_in">
            <form name="form_check_send" action="" method="post" id="form_check_send">
                <div class="boxtitle">
                    <div class="d_input" style="width:3%;"><input type="checkbox" name="checkall" id="checkall" value="" /></div>
                    <div class="d_user" style="width:10%;">Tên đăng nhập</div>
                    <div class="d_fullname" style="width:23%;">Tên đầy đủ</div>
                    <div class="d_email" style="width:18%;">Email</div>
                    <div class="d_user" style="width:18%;">Ngày đăng ký</div>
                    <div class="d_status" style="width:8%;">
                        <?php if($_GET["filter-status"]=="yes") { ?>
                        <a href="<?php echo get_string_url(array('filter-status','page','filter-verified'))."&filter-status=no"; ?>" title="filter">Trạng thái</a>
                        <?php }else { ?>
                        <a href="<?php echo get_string_url(array('filter-status','page','filter-verified'))."&filter-status=yes"; ?>" title="filter">Trạng thái</a>
                        <?php } ?>
                    </div>
                   
                    <div class="d_setting" style="width:12%;">Thao tác</div>
                </div>

                <?php

                while($member=$db->fetch_array($rs_member["member"])) {

                    ?>

                <div class="lineuser">
                    <div class="d_input2" style="width:3%;"><input type="checkbox" name="check[]" id="check" class="check" value="<?php echo $member["username"]; ?>" /></div>
                    <div class="d_email2" style="width:10%;text-align:left"><font class="textbody"><?php echo $member["username"]; ?></font></div>
                    <div class="d_fullname2" style="width:23%;text-align:left"><font class="textbody"><?php echo $member["fullname"]; ?></font></div>
                    <div class="d_email2" style="width:18%;text-align:left"><font class="textbody"><?php echo $member["email"]; ?></font></div>
                    <div class="d_type" style="width:18%;text-align:left"><font class="textbody"><?php echo get_my_date($member["reg_date"]); ?></font></div>
                    <div class="d_type" style="width:8%;"><font class="textbody">

                                <?php
                                if($member["status"]=="yes") {

                                    echo "<a href='".get_string_url(array('active','unactive'))."&unactive=".$member["mem_id"]."'><img src='images/active.gif' alt='unactive' title='unactive' /></a>";

                                }else {

                                    echo "<a href='".get_string_url(array('unactive','active'))."&active=".$member["mem_id"]."'><img src='images/deactive.gif' alt='active' title='active' /></a>";

                                }
                                ?>

                        </font></div>
                   
                    <div class="d_setting2" style="width:12%;">
                        <a href="<?php echo ADMIN_URL; ?>/index.php?module=member&action=member-preview&id=<?php echo $member["mem_id"]; ?>&keepThis=true&TB_iframe=true&height=450&width=400" class="thickbox" ><img src="images/profile.gif" alt="View Profile" title="View Profile" /></a>
                        <a href="index.php?module=member&action=edit&id=<?php echo $member["mem_id"]; ?>"><img src="images/edit.gif" alt="Edit profile" title="Edit profile" /></a>
                        <a href="index.php?module=member&option=send-email&email=<?php echo $member["email"]; ?>"><img src="images/send.png" alt="Send mail" title="Send mail" /></a>
                    </div>
                </div>

                <?php

                }

                ?>
                <div class="boxbutton">
                    <input type="button" name="send_message" value="Gửi tin nhắn cá nhân" class="button" onclick="send_refer('<?php echo ADMIN_URL; ?>');"/>
                    <input type="button" name="delete" value="Xóa mục đã chọn" onclick="delete_member('<?php echo ADMIN_URL; ?>');" class="button" id="cancel"/>
                </div>
                <?php
                // SHOW PAGING
                if($rs_member["total"]>1) {
                    echo "<div class='lineinbox'>";
                    echo paging($rs_member["page"],$rs_member["total"],get_string_url());
                    echo "</div>";
                }
                ?>
            </form>
        </div>
    </div>

</div>
<script type="text/javascript">
    function send_refer(baseurl){
        var mem_arr="";
        var arrCheck = document.form_check_send.check;
        if(arrCheck.length>0){
            for(var i=0;i<arrCheck.length;i++){
                if(arrCheck[i].checked==true){
                    mem_arr = mem_arr+","+arrCheck[i].value;
                }
            }
        }else{
            mem_arr = arrCheck.value;
        }
		var loc = baseurl+'/index.php?module=member&option=send-message&members='+mem_arr.replace(',','');
        window.location = loc;
    }

    function delete_member(baseurl){
		if(confirm('Bạn có chắc muốn xóa (những) thành viên này, tất cả bất động sản, tin nhắn gửi, nhận liên quan đến (những) thành viên này sẽ được xóa khỏi hệ thống?')){
			var mem_arr="";
			var arrCheck = document.form_check_send.check;
			if(arrCheck.length>0){
				for(var i=0;i<arrCheck.length;i++){
					if(arrCheck[i].checked==true){
						mem_arr = mem_arr+","+arrCheck[i].value;
					}
				}
			}else{
				mem_arr = arrCheck.value;
			}
			var paging = "<?php if($rs_member['total']>1) {echo '&page='.$rs_member['page'];} ?>";
			var loc = baseurl+'/index.php?module=member&option=delete-member&members='+mem_arr.replace(',','')+paging;
			window.location = loc;
		}
    }
</script>
<?php
include "inc/right.php";
include ADMIN_INCLUDE_DIR."/footer.php";
?>